package com.agileboot.domain.system.dept.command;

import com.agileboot.domain.system.dept.model.DeptModel;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;

@Data
public class AddDeptCommand {
    /**
     * 父部门ID
     */
    private Long parentId;

    /**
     * 祖级列表
     */
    private String ancestors;

    /**
     * 部门名称
     */
    @NotBlank(message = "部门名称不能为空")
    @Size(max = 30, message = "部门名称长度不能超过30个字符")
    private String deptName;

    /**
     * 显示顺序
     */
    @NotNull(message = "显示顺序不能为空")
    private Integer orderNum;

    /**
     * 负责人
     */
    private String leaderName;

    /**
     * 联系电话
     */
    @Size(max = 11, message = "联系电话长度不能超过11个字符")
    private String phone;

    /**
     * 邮箱
     */
    @Email(message = "邮箱格式不正确")
    @Size(max = 50, message = "邮箱长度不能超过50个字符")
    private String email;

    public DeptModel toModel() {
        DeptModel model = new DeptModel();

        model.setParentId(parentId);
        model.setAncestors(ancestors);
        model.setDeptName(deptName);
        model.setOrderNum(orderNum);
        model.setLeaderName(leaderName);
        model.setPhone(phone);
        model.setEmail(email);

        return model;
    }
}
